package xyz.zdsoft.training_manage_system;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.util.StringUtils;

import java.net.InetAddress;
import java.net.UnknownHostException;

@SpringBootApplication
@ComponentScan({
    "xyz.zdsoft.*"
})
@ServletComponentScan({"xyz.zdsoft.*"})
@MapperScan({"xyz.zdsoft.*.mapper"})
@Slf4j
public class TrainingManageSystemApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext application = SpringApplication.run(TrainingManageSystemApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = null;
        try {
            ip = InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        if (StringUtils.isEmpty(path)) {
            path = "";
        }
        log.info("\n\t----------------------------------------------------------\n\t" +
                "Application  is running! Access URLs:\n\t" +
                "Local访问网址: \t\t http://localhost:" + port + path + "/doc.html" + "\n\t" +
                "Ip访问网址: \t\t\t http://" + ip + ":" + port + path+ "/doc.html" + "\n\t" +
                "Jenkins文档访问网址: \t http://10.8.20.231:8086/doc.html" + "\n\t" +
                "----------------------------------------------------------");

    }

}
